Inverting of Boolean variable not happening after end of every for loop